<?php
/**
 * Created by PhpStorm.
 * User: adminyj
 * Date: 2019/2/26
 * Time: 1:00
 */

namespace app\api\controller;


use think\Controller;
use think\Db;

class Text extends Controller
{

    /**
     * 添加身份证姓名
     * */
    public function test()
    {

        $id_code = input('id_code');
        $name = input('name');

        $data = [
            'card_id' => $id_code,
            'real_name' => $name
        ];

        $count = Db::name('party_member')->count();

        if($count){
            $this->result('','-1','请勿重复提交','json');
        }

        $res = Db::name('party_member')->insert($data);

        if($res){
            $this->result('','1','操作成功','json');
        }else{
            $this->result('','-1','操作失败','json');
        }

    }


    /**
     * 更改地址接口
     * */
    public function change()
    {

        $list = Db::name('help_list')->field('work_address,id')->select();
        foreach ($list as $k => $v){
            $arr = explode ('区',$v['work_address']);
            if(isset($arr[1])){
                $arr2 = explode('镇',$arr[1]);
                if(isset($arr2[1])){
                    $ad = $arr[0]."区-".$arr2[0]."镇-".$arr2[1];
                }else{
                    $ad = $arr[0]."区-".$arr2[0];
                }
            }else{
                $ad =$arr[0];
            }
            $c['work_address'] = $ad;
//            Db::name('help_list')->where(['id' =>$v['id']])->update($c);
        }

    }

}